package com.ruoyi.web.controller.shop_review;

import com.ruoyi.Shop_review.server.domain.ShopReview;
import com.ruoyi.Shop_review.server.service.IShopReviewService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 商品评价管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-22
 */
@RestController
@RequestMapping("/shop_review/shop_review")
public class ShopReviewController extends BaseController
{
    @Autowired
    private IShopReviewService shopReviewService;

    /**
     * 查询商品评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('shop_review:shop_review:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopReview shopReview)
    {
        startPage();
        List<ShopReview> list = shopReviewService.selectShopReviewList(shopReview);
        return getDataTable(list);
    }

    /**
     * 导出商品评价管理列表
     */
    @PreAuthorize("@ss.hasPermi('shop_review:shop_review:export')")
    @Log(title = "商品评价管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopReview shopReview)
    {
        List<ShopReview> list = shopReviewService.selectShopReviewList(shopReview);
        ExcelUtil<ShopReview> util = new ExcelUtil<ShopReview>(ShopReview.class);
        util.exportExcel(response, list, "商品评价管理数据");
    }

    /**
     * 获取商品评价管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop_review:shop_review:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopReviewService.selectShopReviewById(id));
    }

    /**
     * 新增商品评价管理
     */
    @PreAuthorize("@ss.hasPermi('shop_review:shop_review:add')")
    @Log(title = "商品评价管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopReview shopReview)
    {
        return toAjax(shopReviewService.insertShopReview(shopReview));
    }

    /**
     * 修改商品评价管理
     */
    @PreAuthorize("@ss.hasPermi('shop_review:shop_review:edit')")
    @Log(title = "商品评价管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopReview shopReview)
    {
        return toAjax(shopReviewService.updateShopReview(shopReview));
    }

    /**
     * 删除商品评价管理
     */
    @PreAuthorize("@ss.hasPermi('shop_review:shop_review:remove')")
    @Log(title = "商品评价管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopReviewService.deleteShopReviewByIds(ids));
    }
}
